cmake_minimum_required(VERSION 3.18.1)

project("jyyplayer")

# 设置源码路径
set(CURRENT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(LIBS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI})

# 添加头文件和连接库路径
include_directories(${INCLUDE_DIR})
include_directories(${INCLUDE_DIR}/include)
link_directories(${LIBS_DIR})

# 添加外部库
add_library(avcodec SHARED IMPORTED)
set_property(TARGET avcodec PROPERTY IMPORTED_LOCATION ${LIBS_DIR}/libavcodec.so)

add_library(avformat SHARED IMPORTED)
set_property(TARGET avformat PROPERTY IMPORTED_LOCATION ${LIBS_DIR}/libavformat.so)

add_library(avdevice SHARED IMPORTED)
set_property(TARGET avdevice PROPERTY IMPORTED_LOCATION ${LIBS_DIR}/libavdevice.so)

add_library(avfilter SHARED IMPORTED)
set_property(TARGET avfilter PROPERTY IMPORTED_LOCATION ${LIBS_DIR}/libavfilter.so)

add_library(avutil SHARED IMPORTED)
set_property(TARGET avutil PROPERTY IMPORTED_LOCATION ${LIBS_DIR}/libavutil.so)

add_library(swresample SHARED IMPORTED)
set_property(TARGET swresample PROPERTY IMPORTED_LOCATION ${LIBS_DIR}/libswresample.so)

add_library(swscale SHARED IMPORTED)
set_property(TARGET swscale PROPERTY IMPORTED_LOCATION ${LIBS_DIR}/libswscale.so)

add_library(postproc SHARED IMPORTED)
set_property(TARGET postproc PROPERTY IMPORTED_LOCATION ${LIBS_DIR}/libpostproc.so)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L${LIBS_DIR}" )

add_library(
        jyyplayer

        SHARED

        jyyplayer.cpp)

find_library(
        log-lib

        log)

target_link_libraries(
        jyyplayer
        avfilter
        avformat
        avcodec
        avutil
        avdevice
        swresample
        swscale
        postproc
        android
        z
        ${log-lib})